using System;
using System.Collections.Generic;
using Dict.DataModel;

namespace Dict.Dao
{
    public class TableStoryDao:DaoBase<TableStory>
    {
        public override void AddPrimaryIndex(TableStory model)
        {
            cachePrimary[model.id.ToString()] = model;
        }

        public override string GetFileName()
        {
            return "TableStory.txt";
        }

        protected override TableStory ParseRowData(string[] rowData)
        {
            TableStory data = new TableStory();

            if (string.IsNullOrEmpty(rowData[0]))
            {
                data.id = 0;
            }
            else
            {
                data.id = int.Parse(rowData[0]);
            }
			data.questId = rowData [1];

            if (string.IsNullOrEmpty(rowData[2]))
            {
                data.eventType = 0;
            }
            else
            {
                data.eventType = int.Parse(rowData[2]);
            }
			data.eventParam = rowData [3];

            if (string.IsNullOrEmpty(rowData[4]))
            {
                data.actionType = 0;
            }
            else
            {
                data.actionType = int.Parse(rowData[4]);
            }
			data.actionParam1 = rowData [5];
			data.actionParam2 = rowData [6];
			data.actionParam3 = rowData [7];

            return data;
        }


        public override void AddOneIndex(TableStory model)
        {
            if (!cacheOneIndex.ContainsKey(model.questId.ToString()))
            {
                cacheOneIndex[model.questId.ToString()] = new List<TableStory>();
            }
            cacheOneIndex[model.questId.ToString()].Add(model);
        }
    

    }

}
